package packageProgramme;

import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JToolBar;
import javax.swing.SwingConstants;

public class MyToolBar extends JToolBar {
	private JButton iconeAccueil, iconeSortie, iconeAide, iconeDBConnecte, iconeDBDeconnecte, iconeInstall, iconeUninstall, iconeRechercher;

	// CONSTRUCTEURS :
	public MyToolBar () {
		setFloatable(false);
		
		iconeAccueil = new JButton(new ImageIcon("images/logo_accueil.png"));
		iconeAccueil.setFocusable(false);
		iconeAccueil.setOpaque(false);
				
		iconeSortie = new JButton(new ImageIcon("images/logo_sortie.png"));
		iconeSortie.setFocusable(false);
		
		iconeAide = new JButton(new ImageIcon("images/logo_aide.png"));
		iconeAide.setFocusable(false);
		
		iconeDBConnecte = new JButton("Etat de la connexion : ", new ImageIcon("images/logo_db_ok_mini.png"));
		iconeDBConnecte.setHorizontalTextPosition(SwingConstants.LEFT);
		iconeDBConnecte.setFocusable(false);
		
		iconeDBDeconnecte = new JButton("Etat de la connexion : ", new ImageIcon("images/logo_db_warning_mini.png"));
		iconeDBDeconnecte.setHorizontalTextPosition(SwingConstants.LEFT);
		iconeDBDeconnecte.setFocusable(false);
		
		iconeInstall = new JButton(new ImageIcon("images/logo_db_install_mini.png"));
		iconeInstall.setFocusable(false);
		iconeInstall.setEnabled(false);
		
		iconeUninstall = new JButton(new ImageIcon("images/logo_db_uninstall_mini.png"));
		iconeUninstall.setFocusable(false);
		iconeUninstall.setEnabled(false);
		
		iconeRechercher = new JButton(new ImageIcon("images/logo_db_rechercher_mini.png"));
		iconeRechercher.setFocusable(false);
		iconeRechercher.setEnabled(false);
						
		addSeparator(new Dimension(5, 0));
		add(iconeAccueil);
		
		addSeparator(new Dimension(5, 0));
		addSeparator();
		addSeparator(new Dimension(5, 0));
		add(iconeDBDeconnecte);
		
		addSeparator(new Dimension(5, 0));
		addSeparator();
		addSeparator(new Dimension(5, 0));
		add(iconeInstall);
		addSeparator(new Dimension(5, 0));
		add(iconeUninstall);
		addSeparator(new Dimension(5, 0));
		add(iconeRechercher);
		
		addSeparator(new Dimension(5, 0));
		addSeparator();
		addSeparator(new Dimension(5, 0));
		add(iconeAide);
		
		
		addSeparator(new Dimension(5, 0));
		addSeparator();
		addSeparator(new Dimension(5, 0));
		add(iconeSortie);
	}
	
	// GETTORS :
	public JButton getIconeAccueil () {return iconeAccueil;}
	public JButton getIconeSortie () {return iconeSortie;}
	public JButton getIconeAide () {return iconeAide;}
	public JButton getIconeDBConnecte () {return iconeDBConnecte;}
	public JButton getIconeDBDeconnecte () {return iconeDBDeconnecte;}
	public JButton getIconeInstall () {return iconeInstall;}
	public JButton getIconeUninstall () {return iconeUninstall;}
	public JButton getIconeRechercher () {return iconeRechercher;}

	// SETTORS :

	// METHODES :
	public void switchIconeEtatDBConnexionToDeconnexion () {
		remove(iconeDBConnecte);
		add(iconeDBDeconnecte, 5);
		iconeInstall.setEnabled(false);
		iconeUninstall.setEnabled(false);
		iconeRechercher.setEnabled(false);
		repaint();
		validate();
	}

	public void switchIconeEtatDBDeconnexionToConnexion () {
		remove(iconeDBDeconnecte);
		add(iconeDBConnecte, 5);
		iconeInstall.setEnabled(true);
		iconeUninstall.setEnabled(true);
		iconeRechercher.setEnabled(true);
		repaint();
		validate();
	}

}
